package com.wm.platform.user.controller;

import com.wm.base.BaseController;
import com.wm.platform.user.model.User;
import com.wm.platform.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by sevelli on 2017/5/9.
 */
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {
    @Autowired
    private UserService userService;

    @RequestMapping("info/{id}")
    public User info(@PathVariable Long id){
        return userService.getUserById(id);
    }

    @RequestMapping("page")
    public Page<User> page(User user,Integer pageNo,Integer pageSize){
        PageRequest request = buildPageRequest(pageNo,pageSize);
        return userService.getPage(user,request);
    }
}
